// *** ADDED BY HEADER FIXUP ***
#include <wx/string.h>
// *** END ***
// *** ADDED BY HEADER FIXUP ***
#include <wx/xml/xml.h>
// *** END ***
#ifndef PHONEAIMLMANAGER_H_INCLUDED
#define PHONEAIMLMANAGER_H_INCLUDED

#include <map>
#include <wx/socket.h>
#include "Alice/Kernel.h"
#include <wx/thread.h>

class PhoneAiml:wxXmlDocument
{
    wxString queryType, stdQuery;
    bool needWrite;/**< 已取消 无意义 */
public:
    PhoneAiml(const wxString& queryType, const wxString& stdQuery);
    bool Save();
    void AddCategory(const wxString& query, const wxString& that,
                     const wxString& answer, const wxString& name);
    wxString& GetStdQuery();
};

class PhoneAimlManager
{
public:
    PhoneAimlManager(Kernel *kernel);
    ~PhoneAimlManager();
    string AddCategory(wxXmlNode *node,const wxString& name);
    void SendQueryType(wxSocketBase *sock,time_t timeStamp);
    void SaveData();
private:
    wxMutex mutex;
    Kernel *kernel;
    wxXmlDocument typeList;
    void ReadData(const wxString& fp);
    size_t pre;
    map<wxString,PhoneAiml*> mp;
    multimap<time_t,wxString,greater<time_t> > timeSort;
};

#endif // PHONEAIMLMANAGER_H_INCLUDED
